import { deepClone } from '@/utils/index'

function useRef<T extends object>(value: T) {
  const initiaValue = deepClone(value)
  const state = ref(value)

  const reset = () => {
    state.value = deepClone(initiaValue)
  }

  return [state, reset] as [Ref<T>, () => void]
}

export { useRef }
